package org.jeecg.modules.kc.enums;

import org.jeecg.common.system.annotation.EnumDict;
import org.jeecg.common.system.vo.DictModel;

import java.util.ArrayList;
import java.util.List;


@EnumDict("storageEnum")
public enum StorageEnum {

    buy(1, "采购入库"),
    saleReturn(2, "销售退货"),
    profit(3, "盘盈入库"),
    other(4, "其他入库"),
    allot(5, "调拨入库"),
    assets(6, "固资入库"),
    mallReturn(7,"商城退货入库");

    Integer key;

    String title;

    StorageEnum(Integer key, String title) {
        this.key = key;
        this.title = title;
    }

    public Integer getKey() {
        return key;
    }

    public String getTitle() {
        return title;
    }

    /**
     * 获取字典数据
     *
     * @return
     */
    public static List<DictModel> getDictList() {
        List<DictModel> list = new ArrayList<>();
        DictModel dictModel = null;
        for (StorageEnum e : StorageEnum.values()) {
            dictModel = new DictModel();
            dictModel.setValue(e.key.toString());
            dictModel.setText(e.title);
            list.add(dictModel);
        }
        return list;
    }

    public static StorageEnum val(Integer key) {
        for (StorageEnum bld : values()) {
            if (bld.key == key) {
                return bld;
            }
        }
        return null;
    }

}
